﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using System.Threading.Tasks;

namespace HyperlinkTagEditor.App
{
    public static class RuleValidator
    {
        public static bool CancelFoundInUrl(string inputUrl)
        {
            if (inputUrl.ToLower().Contains("cancel"))
                return true;
            else
                return false;
        }
        public static bool ExactMatchForUrl(string inputUrl, List<String> urlList)
        {
            if (urlList.Exists(element => element.ToLower().Equals(inputUrl.ToLower())))
                return true;
            else
                return false;
        }

        

        public static bool QuestionMarkFoundInUrl(string inputUrl)
        {
            return MatchSubStringInUrl(inputUrl, "?");
        }
        public static bool MatchSubStringInUrl(string inputUrl, string subStringToMatch)
        {
            if (inputUrl.Contains(subStringToMatch))
                return true;
            else
                return false;

        }
        public static bool PartialMatchForUrl(string inputUrl, List<String> urlList)
        {
            //if (urlList.Contains(inputUrl.ToLower()))
            //    return true;
            //else
            //    return false;
            bool matchFound = false;
            foreach (var item in urlList)
            {
                if (inputUrl.ToLower().Contains(item.ToLower()))
                {
                    matchFound = true;
                    break;
                }
            }
            return matchFound;
        }



    }

}
